package com.wc.fortnight_blue_bridge.Q16模拟二.E_最大24倍数和;

import java.util.Arrays;

/**
 * @Author congge
 * @Date 2024/11/23 22:00
 * @description
 * https://dasai.lanqiao.cn/pages/v7/dasai/prelim/prelim_examing.html?examUsperPaperId=338843&applyId=579285787961
 */
public class Main {
    /**
     *【问题描述】
     * 小蓝有以下 100 个整数：
     * 534, 386, 319, 692, 169, 338, 521, 713, 640, 692, 969, 362, 311, 349, 308, 357, 515, 140, 591, 216,
     * 57, 252, 575, 630, 95, 274, 328, 614, 18, 605, 17, 980, 166, 112, 997, 37, 584, 64, 442, 495,
     * 821, 459, 453, 597, 187, 734, 827, 950, 679, 78, 769, 661, 452, 983, 356, 217, 394, 342, 697, 878,
     * 475, 250, 468, 33, 966, 742, 436, 343, 255, 944, 588, 734, 540, 508, 779, 881, 153, 928, 764, 703,
     * 459, 840, 949, 500, 648, 163, 547, 780, 749, 132, 546, 199, 701, 448, 265, 263, 87, 45, 828, 634.
     * 小蓝想从中选出一部分数求和，使得和是 24 的倍数，请问这个和最大是多少？
     */
    static int[] a = new int[]{
            534, 386, 319, 692, 169, 338, 521, 713, 640, 692, 969, 362, 311, 349, 308, 357, 515, 140, 591, 216,
            57, 252, 575, 630, 95, 274, 328, 614, 18, 605, 17, 980, 166, 112, 997, 37, 584, 64, 442, 495,
            821, 459, 453, 597, 187, 734, 827, 950, 679, 78, 769, 661, 452, 983, 356, 217, 394, 342, 697, 878,
            475, 250, 468, 33, 966, 742, 436, 343, 255, 944, 588, 734, 540, 508, 779, 881, 153, 928, 764, 703,
            459, 840, 949, 500, 648, 163, 547, 780, 749, 132, 546, 199, 701, 448, 265, 263, 87, 45, 828, 634};

    public static void main(String[] args) {
        int res = 0, minv = 1000;
        for (int i = 0; i < 100; i++){
            res += a[i];
        }
        Arrays.sort(a);
        for (int i = 0; i < 100; i++) {
            if ((res - a[i]) % 24 == 0) {
                System.out.println(a[i]);
                System.out.println(res - a[i]);
                break;
            }
        }
    }
}
